import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
      count:1,
      num:123
  },
  mutations: {
      add(state){ 
        state.count++
      },
      sub(state){
        state.count--
      },
      num_add(state){
        state.num++
      }
  },
  actions: {
    increment ({ commit }) {
      setTimeout(() => {
        commit('add')
      }, 2000);
    },
    action_add ({ commit }) {
      setTimeout(() => {
        commit('num_add')
      }, 2000);
    },


  },

  getters:{
    getterCount(state){
      return "+++++++"+state.count+"+++++++"
    }

  }

})
